package com.juc.forkJoinPool.forkJoinPool8;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future;

public class Test {

	// public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) 
	//有阻塞性
	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws InterruptedException, ExecutionException {
		List list = new ArrayList();
		list.add(new MyCallable(5000));
		list.add(new MyCallable(4000));
		list.add(new MyCallable(3000));
		list.add(new MyCallable(2000));
		list.add(new MyCallable(1000));
		ForkJoinPool pool  =new ForkJoinPool();
		List<Future<String>> listFuture =pool.invokeAll(list);
		for (int i = 0; i < listFuture.size(); i++) {
			System.out.println(listFuture.get(i).get() +  "  nowTime: " + System.currentTimeMillis());
		}
	}
}
